#include <stdio.h>
#include "line.h"
#include "shape.h"
#include "panel.h"

void drawLine(Shape *self, void *panel) {
    Line *line = (Line *)self;
    Panel *p = (Panel *)panel;
    int x = line->base.x;
    int y = line->base.y;
    int length = line->length;
    char direction = line->direction;
    char ch = line->base.ch;

    if (direction == 'H') { // horizontal line
        for (int i = 0; i < length; i++) {
            drawPixel(p, x + i, y, ch);
        }
    } else if (direction == 'V') { // vertical line
        for (int i = 0; i < length; i++) {
            drawPixel(p, x, y + i, ch);
        }
    } else {
        printf("Direction error! Please input 'H' or 'V'.\n");
    }
}

